<template>
	<view class="poFixed wPer100 hPer100 backCol0a0a0aS5 zIndex1 top0 left0"
		v-show="showShareFrame" @touchmove.stop.prevent
	>
		<view class="poFixed top50P left50P trTrn50Pn50P backColWhite borRad30r w700r overHid bSha0010u0rgb00001">
			<view class="lh96r poRel foWeiBold f30r pl30r borB1SCcc">
				<text>
					{{
						shareType == 1 ? '分享开门码' :
						shareType == 2 ? '收到开门码' : shareType
					}}：
				</text>
				<text class="col99c043">
					{{shareCode}}
				</text>
				<image src="/static/icons/iconClose.png" mode="aspectFit"
					class="w50r h50r poAbs rig20r top26r" @click="cliCloseShare"
				></image>
			</view>
			<view class="p20r backColF5f5f5">
				<button open-type="share" v-if="shareType == 1"
					class="lh80r teAliCenter backImgLiGrTR2c6739a99c043 borRad40r bSha0a4a10aCcc notBtnSty f26r colFff p0 overVis"
				>
					一键分享给好友
				</button>
				<button v-if="shareType == 2" @click="cliNowOpen"
					class="lh80r teAliCenter backImgLiGrTR2c6739a99c043 borRad40r bSha0a4a10aCcc notBtnSty f26r colFff p0 overVis"
				>
					立即开门通电
				</button>
				<view class="col999 mt20r pl10r">
					有效期：10分钟
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import { isCodeToSwitch } from '@/utils/api.js'
export default {
	props: {
		showShareFrame: { type: Boolean, default: false },//最外层框 true为显示
		shareCode: { type: String, default: '' },//接口获取的分享开门码
		shareType: { type: Number, defulit: 0 }//面板类型：1为分享方  2为接收方
	},
	methods: {
		cliCloseShare() {
			this.$emit('cliCloseShare');
		},
		cliNowOpen() {
			uni.showModal({
				title: '提示', content: '确定立即开门通电？', confirmColor: '#99c043',
				success:res1 => {
					if (res1.confirm) {
						isCodeToSwitch({
							code: this.shareCode
						}).then(res2 => {
							uni.showModal({
								title: '提示', content: res2.message, confirmColor: '#99c043',
								showCancel: false, confirmText: '我知道了',
								success:res3 => {
									if (res3.confirm) {
										
									}
								}
							})
						})
					}
				}
			})
		}
	}
}
</script>